import { IFeidaoAiBrowserComponent } from '@dfeidao/atom-web/interfaces';
import nodejs from '@dfeidao/atom-web/msg/nodejs';
import refresh from '@dfeidao/atom-web/url/refresh';
import get from '@dfeidao/atom-web/local/get';
export default async function a003(fd: IFeidaoAiBrowserComponent) {
	// todo
	const plan_cla_attr_name = fd.data.node.querySelector<HTMLSelectElement>('[data-id="plan_cla_attr_name"]');
	const post_package_name = fd.data.node.querySelector<HTMLInputElement>('[data-id="post_package_name"]').value;
	let plan = plan_cla_attr_name.value;
	if (!post_package_name) {
		alert("请填写岗位包名称");
		return;
	}
	if (plan === '请选择') {
		alert("请选择计划分类属性名称");
		return;
	} else {
		plan = plan_cla_attr_name.selectedOptions[0].text;
	}
	console.log(plan);
	console.log(post_package_name);
	const plan_type_name = fd.data.node.querySelector<HTMLSelectElement>('[data-id="plan_type_name"]');
	let planname = plan_type_name.value;
	if (planname === '请选择') {
		alert("请选择计划类型名称");
		return;
	} else {
		planname = plan_type_name.selectedOptions[0].text;
	}
	const _id = get(fd, '_id');
	const qq = await nodejs<{ code: 0 | 1 }>('GuoKai/zj-000005/s004', {
		_id: _id,
		post_package_name: post_package_name,
		plan_cla_attr_name: plan,
		plan_type_name: planname,
	});
	if (qq.code === 0) {
		alert("添加失败");
	} else {
		alert("添加成功");
		refresh();
	}
}
